import 'package:flutter/material.dart';
import 'package:flutterdemo/0demo/provider/top_provider/top_provider.dart';
import 'package:provider/provider.dart';

class TestTopPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    int a = context.select((TopProvider provider) => provider.a);

    return Scaffold(
      appBar: AppBar(
        title: Text("top provider"),
      ),
      body: Center(
        child: Column(
          children: [
            Text("a = $a"),
            FlatButton(onPressed: () {
              context.read<TopProvider>().changeA(999);
            }, child: Text("change a")),
          ],
        ),
      ),
    );
  }
}
